/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Action;

import Inrterface.Messages;

/**
 *
 * @author insane
 */
public class See {

    private static final String empty = "Empty room";
    private static final String door = "Closed door";
    private static final String wall = "Wall";
    private static final String chest = "Closed chest";
    private static final String passage = "Passage";
    private static final String uptrans = "Up staircase";
    private static final String downtrans = "Down staircase";
    private static final String deadlock = "deadlock";
    private static String text = null;
    private static int countWall = 0;

    private See() {
    }

    public static void checkSee(int x, int y, char[][] map) {
        for (int w = x - 1; w <= x + 1; w++) {
            for (int h = y - 1; h <= y + 1; h++) {
                if (check(map[w][h]) != 0) {
                    countWall = 0;
                    Messages.getInstance().add(text);
                    return;
                }
            }
        }
        if (countWall == 0) {
            text = empty;
        }
        if (countWall == 2) {
            text = passage;
        }
        if (countWall > 2) {
            text = wall;
        }
        if (countWall == 5) {
            text = deadlock;
        }
        countWall = 0;
        Messages.getInstance().add(text);
        return;

    }

    private static int check(char wtf) {
        switch (wtf) {
            case '+':
                text = door;
                return 1;
            case '<':
                text = uptrans;
                return 1;
            case '>':
                text = downtrans;
                return 1;
            case '*':
                text = chest;
                return 1;
            case '#':
                countWall++;
                return 0;

        }
        return 0;
    }

    public static String getMessage() {
        if (text == null) {
            return "";
        }
        return text;
    }
    
}
